package com.aloda.controller.admin;

import cn.hutool.core.bean.BeanUtil;
import com.aloda.dto.PageEditDTO;
import com.aloda.entity.PageContent;
import com.aloda.result.Result;
import com.aloda.service.PageContentService;
import com.aloda.vo.PageContentVO;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/admin/page")
@RestController("admin-page")
public class PageContentController {

    @Resource
    private PageContentService pageContentService;

    /**
     * 保存关于页面内容
     * @param pageEditDTO
     * @return
     */
    @PostMapping("/about")
    public Result saveAboutPage(@RequestBody PageEditDTO pageEditDTO) {
        pageContentService.saveAboutPage(pageEditDTO);
        return Result.success();
    }

    /**
     * 获取关于页面内容
     * @return
     */
    @GetMapping("/about")
    public Result<PageContentVO> getAboutPage() {
        PageContentVO pageContentVO = pageContentService.getAboutPage();
        return Result.success(pageContentVO);
    }
}
